﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using WinHBM.Core.Net.Sockets.Cmd;
using WinHBM.Core.Net.Http;

namespace WinHBM.Core.Net.Sockets.Cmd
{
    public class TestLoginCmd : SocketCmd
    {
        public override void executeCmd(JObject request, FlashSocketServer socket)
        {
            bool isLogin = TokenHolder.isLogin;
            JObject ret = new JObject();
            //ret["is_login"] = isLogin ? 1 : 0;
            ret["status"] = -1;

            if (!isLogin)
            {
                ret["status"] = LoginStatus.NO_LOGIN;
            }
            else
            {
                ret["status"] = LoginStatus.LOGINED;
                if (LoginStatus.SYNC_BABY == 1)//正在同步
                {
                    ret["status"] = LoginStatus.SYNC;
                }
                else if(LoginStatus.SYNC_BABY == 2)//同步完成
                {
                    ret["status"] = LoginStatus.SYNC_OK;
                }
                else if (LoginStatus.SYNC_BABY == 3)//同步出错
                {
                    ret["status"] = LoginStatus.SYNC_ERROR;
                }
            }


            socket.Send(wrapCmd(CMD_TEST_LOGIN, ret));
        }
    }
}
